package n08.first;
public class Student implements Comparable<Student>{
    // 成员变量
    private String studentId; // 学号
    private String name;      // 姓名
    private int age;          // 年龄
    private double height;    // 身高（单位：米）
	@Override
	public int compareTo(Student stu) {
		return this.age-stu.age; //按年龄来比较大小
	}
    // 构造方法
    public Student(String studentId, String name, int age, double height) {
        this.studentId = studentId;
        this.name = name;
        this.age = age;
        this.height = height;
    }

    // Getter 和 Setter 方法
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    // 重载 toString 方法
    @Override
    public String toString() {
        return "Student{" +
                "studentId='" + studentId + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height + "m" +
                '}';
    }

    // 测试方法
    public static void main(String[] args) {
        // 创建一个 Student 对象
        Student student = new Student("20240101", "张三", 20, 1.75);
        // 打印对象信息
        System.out.println(student);
    }


}